<%@ page import="login.User" %>
<%--
  Home Page
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>
    <title>Home</title>
</head>
<body style="background-color: #c0c0c0">

<script>

    /**
     * Sample document signing in home page. It does not require PIN because user already logged in.
     */
    function signDocument() {

        alert("Document will be signed with the signer in the applet. No need for PIN while logged in.");
        parent.document.webloginapplet.signDocument(doc);
    }

</script>


    <%
        User user = (User) session.getAttribute("user");

        if(user != null) {
            if(user.isLoggedIn()) {
                out.write("Welcome " + user.getUsername());
            }
            else {
                response.sendRedirect("login.jsp");
            }
        }
    %>

    <form action="logout.jsp" method="post">
        <input type="submit" value="Logout">
    </form>

    <form name="documentSigning" action="signatureValidate" method="post">
        <input id="doc" name="doc" type="text" value="This is the document to be signed"/>
        <input id="signature64" name="signature64" type="hidden" value="nosignature"/>
        <input type="submit" value="Sign" onclick="signDocument()">
    </form>

    <%
        if(user != null && user.getMessage() != "")
            out.write(user.getMessage());
    %>

</body>
</html>